<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>mainwindow.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-widgets-tablet-example.html">Tablet Example</a></td><td >mainwindow.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">mainwindow.cpp 示例文件</h1>
<span class="subtitle">widgets/tablet/mainwindow.cpp</span>
<!-- $$$widgets/tablet/mainwindow.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="preprocessor">#include &quot;mainwindow.h&quot;</span>
  <span class="preprocessor">#include &quot;tabletcanvas.h&quot;</span>

  MainWindow<span class="operator">::</span>MainWindow(TabletCanvas <span class="operator">*</span>canvas)
    : m_canvas(canvas)<span class="operator">,</span> m_colorDialog(nullptr)
  {
      createMenus();
      setWindowTitle(tr(<span class="string">&quot;Tablet Example&quot;</span>));
      setCentralWidget(m_canvas);
      <span class="type"><a href="../qtcore/qcoreapplication.html">QCoreApplication</a></span><span class="operator">::</span>setAttribute(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>AA_CompressHighFrequencyEvents);
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>setBrushColor()
  {
      <span class="keyword">if</span> (<span class="operator">!</span>m_colorDialog) {
          m_colorDialog <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcolordialog.html">QColorDialog</a></span>(<span class="keyword">this</span>);
          m_colorDialog<span class="operator">-</span><span class="operator">&gt;</span>setModal(<span class="keyword">false</span>);
          m_colorDialog<span class="operator">-</span><span class="operator">&gt;</span>setCurrentColor(m_canvas<span class="operator">-</span><span class="operator">&gt;</span>color());
          connect(m_colorDialog<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qcolordialog.html">QColorDialog</a></span><span class="operator">::</span>colorSelected<span class="operator">,</span> m_canvas<span class="operator">,</span> <span class="operator">&amp;</span>TabletCanvas<span class="operator">::</span>setColor);
      }
      m_colorDialog<span class="operator">-</span><span class="operator">&gt;</span>setVisible(<span class="keyword">true</span>);
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>setAlphaValuator(<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>action)
  {
      m_canvas<span class="operator">-</span><span class="operator">&gt;</span>setAlphaChannelValuator(action<span class="operator">-</span><span class="operator">&gt;</span>data()<span class="operator">.</span>value<span class="operator">&lt;</span>TabletCanvas<span class="operator">::</span>Valuator<span class="operator">&gt;</span>());
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>setLineWidthValuator(<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>action)
  {
      m_canvas<span class="operator">-</span><span class="operator">&gt;</span>setLineWidthType(action<span class="operator">-</span><span class="operator">&gt;</span>data()<span class="operator">.</span>value<span class="operator">&lt;</span>TabletCanvas<span class="operator">::</span>Valuator<span class="operator">&gt;</span>());
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>setSaturationValuator(<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>action)
  {
      m_canvas<span class="operator">-</span><span class="operator">&gt;</span>setColorSaturationValuator(action<span class="operator">-</span><span class="operator">&gt;</span>data()<span class="operator">.</span>value<span class="operator">&lt;</span>TabletCanvas<span class="operator">::</span>Valuator<span class="operator">&gt;</span>());
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>setEventCompression(bool compress)
  {
      <span class="type"><a href="../qtcore/qcoreapplication.html">QCoreApplication</a></span><span class="operator">::</span>setAttribute(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>AA_CompressTabletEvents<span class="operator">,</span> compress);
  }

  bool MainWindow<span class="operator">::</span>save()
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> path <span class="operator">=</span> <span class="type"><a href="../qtcore/qdir.html">QDir</a></span><span class="operator">::</span>currentPath() <span class="operator">+</span> <span class="string">&quot;/untitled.png&quot;</span>;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getSaveFileName(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;Save Picture&quot;</span>)<span class="operator">,</span>
                               path);
      bool success <span class="operator">=</span> m_canvas<span class="operator">-</span><span class="operator">&gt;</span>saveImage(fileName);
      <span class="keyword">if</span> (<span class="operator">!</span>success)
          <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>information(<span class="keyword">this</span><span class="operator">,</span> <span class="string">&quot;Error Saving Picture&quot;</span><span class="operator">,</span>
                                   <span class="string">&quot;Could not save the image&quot;</span>);
      <span class="keyword">return</span> success;
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>load()
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName <span class="operator">=</span> <span class="type"><a href="qfiledialog.html">QFileDialog</a></span><span class="operator">::</span>getOpenFileName(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;Open Picture&quot;</span>)<span class="operator">,</span>
                                                      <span class="type"><a href="../qtcore/qdir.html">QDir</a></span><span class="operator">::</span>currentPath());

      <span class="keyword">if</span> (<span class="operator">!</span>m_canvas<span class="operator">-</span><span class="operator">&gt;</span>loadImage(fileName))
          <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>information(<span class="keyword">this</span><span class="operator">,</span> <span class="string">&quot;Error Opening Picture&quot;</span><span class="operator">,</span>
                                   <span class="string">&quot;Could not open picture&quot;</span>);
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>clear()
  {
      <span class="keyword">if</span> (<span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>question(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;Save changes&quot;</span>)<span class="operator">,</span> tr(<span class="string">&quot;Do you want to save your changes?&quot;</span>)<span class="operator">,</span>
                                <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Save <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Discard <span class="operator">|</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Cancel<span class="operator">,</span>
                                <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Save) <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>Save <span class="operator">|</span><span class="operator">|</span> save())
          m_canvas<span class="operator">-</span><span class="operator">&gt;</span>clear();
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>about()
  {
      <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>about(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">&quot;About Tablet Example&quot;</span>)<span class="operator">,</span>
                         tr(<span class="string">&quot;This example shows how to use a graphics drawing tablet in Qt.&quot;</span>));
  }

  <span class="type">void</span> MainWindow<span class="operator">::</span>createMenus()
  {
      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>fileMenu <span class="operator">=</span> menuBar()<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;File&quot;</span>));
      fileMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Open...&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>load<span class="operator">,</span> <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span><span class="operator">::</span>Open);
      fileMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Save As...&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>save<span class="operator">,</span> <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span><span class="operator">::</span>SaveAs);
      fileMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;New&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>clear<span class="operator">,</span> <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span><span class="operator">::</span>New);
      fileMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;E&amp;xit&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>close<span class="operator">,</span> <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span><span class="operator">::</span>Quit);

      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>brushMenu <span class="operator">=</span> menuBar()<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;Brush&quot;</span>));
      brushMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Brush Color...&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>setBrushColor<span class="operator">,</span> tr(<span class="string">&quot;Ctrl+B&quot;</span>));

      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>tabletMenu <span class="operator">=</span> menuBar()<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;Tablet&quot;</span>));
      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>lineWidthMenu <span class="operator">=</span> tabletMenu<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;Line Width&quot;</span>));

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>lineWidthPressureAction <span class="operator">=</span> lineWidthMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Pressure&quot;</span>));
      lineWidthPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>PressureValuator);
      lineWidthPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);
      lineWidthPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>lineWidthTiltAction <span class="operator">=</span> lineWidthMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Tilt&quot;</span>));
      lineWidthTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>TiltValuator);
      lineWidthTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>lineWidthFixedAction <span class="operator">=</span> lineWidthMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Fixed&quot;</span>));
      lineWidthFixedAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>NoValuator);
      lineWidthFixedAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qactiongroup.html">QActionGroup</a></span> <span class="operator">*</span>lineWidthGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qactiongroup.html">QActionGroup</a></span>(<span class="keyword">this</span>);
      lineWidthGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(lineWidthPressureAction);
      lineWidthGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(lineWidthTiltAction);
      lineWidthGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(lineWidthFixedAction);
      connect(lineWidthGroup<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qactiongroup.html">QActionGroup</a></span><span class="operator">::</span>triggered<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span>
              <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>setLineWidthValuator);

      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>alphaChannelMenu <span class="operator">=</span> tabletMenu<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;Alpha Channel&quot;</span>));
      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>alphaChannelPressureAction <span class="operator">=</span> alphaChannelMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Pressure&quot;</span>));
      alphaChannelPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>PressureValuator);
      alphaChannelPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>alphaChannelTangentialPressureAction <span class="operator">=</span> alphaChannelMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;T&amp;angential Pressure&quot;</span>));
      alphaChannelTangentialPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>TangentialPressureValuator);
      alphaChannelTangentialPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);
      alphaChannelTangentialPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>alphaChannelTiltAction <span class="operator">=</span> alphaChannelMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Tilt&quot;</span>));
      alphaChannelTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>TiltValuator);
      alphaChannelTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>noAlphaChannelAction <span class="operator">=</span> alphaChannelMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;No Alpha Channel&quot;</span>));
      noAlphaChannelAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>NoValuator);
      noAlphaChannelAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qactiongroup.html">QActionGroup</a></span> <span class="operator">*</span>alphaChannelGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qactiongroup.html">QActionGroup</a></span>(<span class="keyword">this</span>);
      alphaChannelGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(alphaChannelPressureAction);
      alphaChannelGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(alphaChannelTangentialPressureAction);
      alphaChannelGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(alphaChannelTiltAction);
      alphaChannelGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(noAlphaChannelAction);
      connect(alphaChannelGroup<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qactiongroup.html">QActionGroup</a></span><span class="operator">::</span>triggered<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>setAlphaValuator);

      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>colorSaturationMenu <span class="operator">=</span> tabletMenu<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;Color Saturation&quot;</span>));

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>colorSaturationVTiltAction <span class="operator">=</span> colorSaturationMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Vertical Tilt&quot;</span>));
      colorSaturationVTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>VTiltValuator);
      colorSaturationVTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>colorSaturationHTiltAction <span class="operator">=</span> colorSaturationMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Horizontal Tilt&quot;</span>));
      colorSaturationHTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>HTiltValuator);
      colorSaturationHTiltAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>colorSaturationPressureAction <span class="operator">=</span> colorSaturationMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;Pressure&quot;</span>));
      colorSaturationPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>PressureValuator);
      colorSaturationPressureAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>noColorSaturationAction <span class="operator">=</span> colorSaturationMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;&amp;No Color Saturation&quot;</span>));
      noColorSaturationAction<span class="operator">-</span><span class="operator">&gt;</span>setData(TabletCanvas<span class="operator">::</span>NoValuator);
      noColorSaturationAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);
      noColorSaturationAction<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      <span class="type"><a href="qactiongroup.html">QActionGroup</a></span> <span class="operator">*</span>colorSaturationGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qactiongroup.html">QActionGroup</a></span>(<span class="keyword">this</span>);
      colorSaturationGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(colorSaturationVTiltAction);
      colorSaturationGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(colorSaturationHTiltAction);
      colorSaturationGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(colorSaturationPressureAction);
      colorSaturationGroup<span class="operator">-</span><span class="operator">&gt;</span>addAction(noColorSaturationAction);
      connect(colorSaturationGroup<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qactiongroup.html">QActionGroup</a></span><span class="operator">::</span>triggered<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>setSaturationValuator);

      <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>compressAction <span class="operator">=</span> tabletMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;Co&amp;mpress events&quot;</span>));
      compressAction<span class="operator">-</span><span class="operator">&gt;</span>setCheckable(<span class="keyword">true</span>);
      connect(compressAction<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qaction.html">QAction</a></span><span class="operator">::</span>toggled<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>setEventCompression);

      <span class="type"><a href="qmenu.html">QMenu</a></span> <span class="operator">*</span>helpMenu <span class="operator">=</span> menuBar()<span class="operator">-</span><span class="operator">&gt;</span>addMenu(<span class="string">&quot;&amp;Help&quot;</span>);
      helpMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;A&amp;bout&quot;</span>)<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>MainWindow<span class="operator">::</span>about);
      helpMenu<span class="operator">-</span><span class="operator">&gt;</span>addAction(tr(<span class="string">&quot;About &amp;Qt&quot;</span>)<span class="operator">,</span> <a href="qapplication.html#qApp">qApp</a><span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">::</span>aboutQt);
  }

</pre>
</div>
<!-- @@@widgets/tablet/mainwindow.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
